package com.xuerhua.yxt.controller.sys.student;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.xuerhua.yxt.controller.BaseController;
import com.xuerhua.yxt.model.Grid;
import com.xuerhua.yxt.page.Page;
import com.xuerhua.yxt.reqVo.StudentReqVO;
import com.xuerhua.yxt.service.IStudentService;
import com.xuerhua.yxt.view.StudentTotalView;

@RequestMapping("sys/student/total")
@Controller
public class SysStudentTotalController extends BaseController {
	
	@Autowired
	private IStudentService studentService;
	
	@RequestMapping(value={"","/"})
	public String Index(Model model) {
		return "sys/student/total";
	}
	
	@RequestMapping("pageQuery")
	@ResponseBody Object pageQuery(StudentReqVO vo){
		try {
			vo.setTermKey(getCurrentTerm().getTermKey());
			vo.setFinishYear(getCurrentTerm().getFinishYear());
			Page<StudentTotalView> page = new Page<>();
			page.setPageNo(vo.getPage());
			page.setPageSize(vo.getRows());
			page.setParams(vo);
			List<StudentTotalView> list = studentService.selectStudentTotal(page);
			Grid grid = new Grid();
			grid.setRows(list);
			grid.setTotal(page.getTotalRecord());
			return grid;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

}
